﻿using MediatR;
using T.Contract.API.Application.Command.ContractCommand;
using T.Contract.Domain.T.Contract.Model;
using T.Contract.Repository.Interface;

namespace T.Contract.API.Application.CommandHandlers.ContractHandler
{
    public class ContractTStateupdateCommandHandler : IRequestHandler<ContractTStateupdateCommand, int>
    {
        protected readonly IContractRepository contractRepository;

        public ContractTStateupdateCommandHandler(IContractRepository contractRepository)
        {
            this.contractRepository = contractRepository;
        }

        public async Task<int> Handle(ContractTStateupdateCommand request, CancellationToken cancellationToken)
        {
            var res =await contractRepository.GetModelAsync(request.ContractId);
            res.CcontractStatus = 2;
            res.UpdatedBy=request.UpdatedBy;
            res.UpdatedDate = request.UpdatedDate;
            await contractRepository.UpdateAsync(res);
            return 1;

        }
    }
}
